<?php
/**
 * Created by PhpStorm.
 * User: Duyonggao
 * Date: 2018/1/25 0025
 * Time: 下午 3:34
 */
$path = \yii\helpers\Url::to(['test/url']);
$js = <<<Js
$("#get").on("click",function(){
    $.post("{$path}",{url:$("#url").val()},function(json){
        if(json.code == 200){
            $("#txt").html(json.data.url);
        }
    },'json');
});
Js;
$this->registerJs($js,\yii\web\View::POS_END);
?>
<input type="text" id="url" value="" placeholder="请输入页面链接">
<button id="get">抓取页面链接</button>
<div id="txt">

</div>